home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / pgm_util / editbats / editbats.txt < prev    next >
Encoding:
Text File  |  1994-12-26  |  8.2 KB  |  156 lines

  1. First the nasty business...
  2.  
  3. AUTHOR'S DISCLAIMER
  4. The author makes absolutely NO claims of responsibilty of any kind, including
  5. but not limited to, accuracy, completeness or undesirable effects resulting 
  6. from the procedure described below.  Perform the following at your own risk.  
  7. It is very possible that that you or even another program has modified your 
  8. Windows setup so that the information below is either innacurate or incomplete.
  9. The importance of making backup files cannot be stressed enough.  That's why
  10. it is part of the step by step procedure described below.  This disclaimer
  11. includes the program which accompanies this text file.
  12.  
  13. Enough said...on to the good part...
  14.  
  15. Here's a little trick I use to allow quick and easy editing of batch files 
  16. under Windows.  Please print this file so you have reference to it while you 
  17. are performing this procedure.  The steps labeled with numbers are the main 
  18. steps to perform.  The "sub-steps" labeled with lowercase letters are DOS 
  19. commands to accomplish the associated main step.  Whenever the instructions 
  20. say to type something, what you should type is enclosed in quotes.  Do NOT 
  21. type the quotes themselves.  There are 2 different procedures you can choose
  22. from.  Use whichever one you prefer; they both accomplish the same thing.
  23.  
  24.  
  25. PROCEDURE 1
  26. 1.  If you're running Windows, exit to DOS (not a DOS prompt under Windows).
  27.  
  28. 2.  Switch to your Windows directory and make a backup of your WIN.INI file.  
  29.     If anything goes wrong, you can easily restore your WIN.INI file.
  30.     
  31.     a. CD\WINDOWS
  32.     b. COPY WIN.INI WIN.BAK
  33.  
  34. 3.  Open WIN.INI in any ASCII text editor.  MS-DOS Editor works very well for 
  35.     this, as most people should have this program.
  36.     
  37.     a. EDIT WIN.INI
  38.  
  39. 4.  Several lines from the top of the file, there should be a line that looks 
  40.     like "Programs=com exe bat pif".  Change this to read 
  41.     "Programs=com exe pif".  Save the file and exit MS-DOS Editor.  What this 
  42.     line does is to tell Windows which file extensions are executable 
  43.     programs; in other words, programs that can be run by specifying the file
  44.     name.  By removing the "bat", we are telling Windows that files with a 
  45.     .bat extension cannot be executed.
  46.  
  47. 5.  Find the file REG.DAT in your Windows directory and make a backup of it.
  48.  
  49.     a.  CD\WINDOWS
  50.     b.  COPY REG.DAT REG.BAK
  51.  
  52. 6.  Start Windows and then start File Manager.  Highlight, but do not double 
  53.     click on, any file with a .bat extension.  Pull down the File Menu and 
  54.     select Associate... from it.  Scroll through the list of entries until you 
  55.     find one for Text File.  Select this and click the OK button.  This step 
  56.     makes one major assumption, and that is that the Text File entry has not
  57.     been previously altered.  Windows associates Text Files with Notepad 
  58.     automatically during the initial Windows Setup.  Some installation programs
  59.     may have altered this to use their own text editor.  There is a very simple 
  60.     test to determine this:  In File Manager, double click on any file under 
  61.     50K that has an extension of .txt.  If Notepad starts with that file 
  62.     opened, you're all set.  If a program other than Notepad starts with that
  63.     file opened, the only difference should be that the batch file will be 
  64.     opened in that editor and not Notepad.  If you get a message stating that
  65.     no association exists, consult pages 130 - 132  of your Windows User's 
  66.     Guide.
  67.  
  68. 6.  You're all done!  Simple, huh?
  69.  
  70. PROCEDURE 2
  71.  
  72. 1.  If you have the Visual Basic runtime module version 3 (vbrun300.dll), run
  73.     the program which accompanies this text file.
  74.  
  75. 2.  You're all done!  Really simple, huh?
  76.  
  77. This program will automatically create the backup files and verify that .txt
  78. files are associated with an application.  It will then configure .bat files
  79. to use that same association.  If .txt files are not associated with any 
  80. application, you will be given the option of creating the default Windows
  81. configuration of associating .txt and .ini files with Notepad, as well as
  82. associating .bat files with Notepad.  After successfully updating Windows,
  83. you will be asked whether or not to re-start Windows.
  84.  
  85.  
  86. You'll now be able to double click on almost any file with a .bat extension 
  87. and that file will be opened up inside of Notepad, ready for editing.  I say 
  88. almost any file because files in Notepad are limited to approximately 50K.  I 
  89. have personally never seen or even heard of a batch file this large, but that 
  90. doesn't mean some guru didn't write one.
  91.  
  92. You can also specify the batch file using the File|Run command of 
  93. Program Manager or File Manager.  For example, in the Command Line box, just 
  94. type any file name that has a .bat extension.  You do not need to specify 
  95. Notepad in the command line, but you MUST include the .bat extension.  Windows 
  96. will know that this file should be opened up inside of Notepad.
  97.  
  98. You're probably now saying "Well, that's all fine and dandy, but how do I RUN 
  99. my batch programs?"  Remember that "Programs=" line in WIN.INI?  There was an 
  100. extension on that line called pif.  For those that are not familiar with these 
  101. types of files, PIF stands for Program Information File.  These files are 
  102. basically data files that tell Windows how to run DOS programs, but they can 
  103. be executed like conventional program files.  You create and edit PIFs using 
  104. the PIF Editor, which should be located in the Main program group of Program 
  105. Manager.  Open PIF Editor and in the Program Filename box, type the file name 
  106. of any batch program.  Set all the other options as necessary.  Most batch 
  107. files are relatively small, therefore, it is not usually necessary to provide 
  108. a lot of memory for them.  For the Memory Requirements settings, try specifying 
  109. 256K for KB Required and 384K or less for KB Desired, but do NOT set KB Desired 
  110. lower than what you have for KB Required.  For EMS and XMS Memory settings, 
  111. you can probably specify 0 for all 4 settings.  For information on all the 
  112. other settings and options for PIFs, see your Windows User Guide or simply 
  113. bring up the PIF Editor Help.
  114.  
  115. Now that you've got the PIF configured properly, pull down the File Menu and 
  116. select the Save As... command.  Use the Directories and/or Drive boxes to 
  117. change to the same directory that your batch file is located in and type in 
  118. the same file name as the batch file, but substitute the extension "pif" for 
  119. "bat".  For example, if your batch file is called "myprog.bat", type 
  120. "myprog.pif" in the File Name box.  Click the OK button to save the PIF.  
  121. Now to run the batch file, simply double click on the PIF file instead of the 
  122. BAT file in File Manager, or from the File|Run command type "myprog.pif" 
  123. instead of "myprog.bat".
  124.  
  125. The program which is included in this archive, obviously, cannot create the 
  126. PIFs for you.  You must do that yourself.
  127.  
  128. There are many variations to this setup that you can make.  For example, you 
  129. can specify the full path to the batch file in the Program Filename box of the 
  130. PIF Editor and keep all your PIFs together in one directory and still be able 
  131. to execute all your batch files.  Personally, I prefer to keep PIFs used for 
  132. starting batch files in the same directory as the batch file and sort the files 
  133. in File Manager by their name.  That way, the PIF and the BAT files are right 
  134. next to each other.  PIFs that are used to start DOS programs, such as MS-DOS 
  135. Editor, I keep in a subdirectory called PIFS off of the Windows directory.  
  136. I then create an icon in Program Manager and specify the appropriate directory 
  137. in the Working Directory box of the Program Item Properties dialog.
  138.  
  139. I hope that you find this tip useful.  If you find that you don't like it,
  140. well, that's what the backups are for.  Simply rename them back to their 
  141. original filename and all will be as it was.
  142.  
  143. For any VB programmers out there, I have also included the VB source code for
  144. the program, if you want to take a closer look at exactly what the program
  145. does.  The source code is fully commented.  Feel free to use anything in it
  146. for use in your own programs.
  147.  
  148. If you have any questions or there is something that I didn't make clear,
  149. I can be reached through E-Mail at VDG Mike on America Online and at 
  150. 73122,1474 on CompuServe.
  151.  
  152. Happy Computing!
  153.  
  154. Mike Davis
  155.  
  156.